package org.covalence.core.util;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.covalence.core.Constants;
import org.covalence.core.Strings;

public class CTable implements Constants {

	private static Map<String, String> table = 
		Collections.synchronizedMap(new HashMap<String, String>());
	
	static {
		table.put(CLIST, CLIST);
		table.put(LIST, CLIST);
		table.put(ARRAY_LIST, CLIST);
		table.put(LINKED_LIST, CLIST);
		
		table.put(CSET, CSET);
		table.put(SET, CSET);
		table.put(HASH_SET, CSET);
		table.put(TREE_SET, CSET);
		table.put(SORTED_SET, CSET);
		table.put(LINKED_HASH_SET, CSET);
		
		table.put(CMAP, CMAP);
		table.put(MAP, CMAP);
		table.put(HASH_MAP, CMAP);
		table.put(TREE_MAP, CMAP);
		table.put(LINKED_HASH_MAP, CMAP);
	}
	
	public static String translate(String key) {
		return table.get(Strings.descriptorToClassname(key));
	}

	public static boolean isCollectionType(String desc) {
		return table.containsKey(Strings.descriptorToClassname(desc));
	}
}
